package com.lovergreen.person.model;


import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;

import javax.persistence.*;
import javax.validation.constraints.Size;

@Entity
@Table(name = "person")

public class Person {
    @Size(min = 2, max = 100)
    @Email
    @NotEmpty
    private String email;
    private String password;
    private Boolean active;
    private String firstname;
    private String lastname;
    private String cellphone;
    private String confirmkey;
    private PersonRole personRole;

    public Person() {
    }

    public Person(String email, String password, boolean active) {
        this.email = email;
        this.password = password;
        this.active = active;
    }

    public Person(String email, String password, boolean active, PersonRole personRole) {
        this.email = email;
        this.password = password;
        this.active = active;
        this.personRole = personRole;
    }

    @Id
    @Column(name = "email", unique = true, nullable = false, length = 50)
    public String getEmail() { return email; }
    public void setEmail(String email) { this.email = email; }

    @Column(name = "password", nullable = false, length = 16)
    public String getPassword() { return password; }
    public void setPassword(String password) { this.password = password; }

    @Column(name = "active", nullable = false)
    public Boolean getActive() {return active;}
    public void setActive(Boolean active) { this.active = active; }

    @Column(name = "firstname", nullable = true, length = 45)
    public String getFirstname() { return firstname; }
    public void setFirstname(String firstname) { this.firstname = firstname; }

    @Column(name = "lastname", nullable = true, length = 45)
    public String getLastname() { return lastname; }
    public void setLastname(String lastname) { this.lastname = lastname; }

    @Column(name = "cellphone", nullable = true, length = 15)
    public String getCellphone() { return cellphone; }
    public void setCellphone(String cellphone) { this.cellphone = cellphone; }

    @Column(name = "confirmkey", nullable = false, length = 28)
    public String getConfirmkey() { return confirmkey; }
    public void setConfirmkey(String confirmkey) { this.confirmkey = confirmkey; }

    @ManyToOne(cascade = CascadeType.ALL)
    public PersonRole getPersonRole() { return personRole; }
    public void setPersonRole(PersonRole personRole) { this.personRole = personRole; }
}
